package 牛客_面试必刷.Month07.day10;

public class 合并二叉树 {
    public TreeNode mergeTrees (TreeNode t1, TreeNode t2) {
        // write code here
        TreeNode root = slove(t1,t2);
        return root;
    }

    public TreeNode slove(TreeNode t1, TreeNode t2) {
        // write code here
        if(t1 == null) return t2;
        if(t2 == null) return t1;
        int val = 0;
        TreeNode node = new TreeNode(t1.val + t2.val);
        node.left = slove(t1.left,t2.left);
        node.right = slove(t1.right,t2.right);
        return node;
    }
}
